<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			//字符串长度获取
			var str = "abcd,老";
			function bytesLength(str){
				var count = 0;
			for(var i = 0; i<str.length; i++){
				if(str.charCodeAt(i)>255){
					count = count+2;
				}else{
					count++;
				}
			}
			return count;
			}
			var n = bytesLength(str);
			console.log(n);
		</script>
	</head>
	<body>
	</body>
</html>
